this.name           = "probeLaunch";
this.author         = "Thargoid";
this.copyright      = "September 2009";
this.description    = "Spawn probe with correct heading and AI";
this.version        = "1.10";

this.shipDied = function() 
	{ 
	let probe = this.ship.spawnOne('probe_probeMissile');
	let probeOrientation = this.ship.owner.orientation; 
	let offsetVector = probeOrientation.vectorUp(); // vector at right angles to the ship/probe, downwards
	let spawnOffset = offsetVector.multiply(50); // set the offset to 50m downwards (for larger ships, increase 50).
	if (oolite.compareVersion('1.73') <= 0) 
		{
		probe.orientation = probeOrientation; // point the probe in the same direction as the player
		probe.position = this.ship.position.subtract(spawnOffset); // move the probe to it's correct start point.
		}
	else 
		{
		probe.setOrientation(probeOrientation); // point the probe in the same direction as the player
		probe.setPosition(this.ship.position.subtract(spawnOffset)); // move the probe to it's correct start point.
            }
	probe.switchAI('probe_probeMissileAI.plist'); // confirm it's using the correct AI after spawn (no autoAI).
	}

